import http from "@/utils/http";

export enum PRIZE_IDS {
    '迪士尼门票' = 115,
    '背包' = 116,
    '贴纸' = 117,
    '盲盒' = 118,
}

// ### 填写收货地址
export function FillAddress(params: {
    address: string
    name: string
    phone: string
    id?: number | string
}) {
    return http.post(`/api/bactroban-bus/address`, params)
}

// ###抽奖
export function Reward(): Promise<{
    create_time: string
    id: number
    lottery_result: number
    prize_name: string
    prize_img: string
    type: number // ?奖品类型
    user_id: number
}> {
    return http.post(`/api/bactroban-bus/reward`).then(res => res?.data)
}


// ### 中奖列表
export type RewardProps = {
    address: string
    code: string
    create_time: string
    id: number
    lottery_result: PRIZE_IDS
    name: string
    phone: string
    prize_img: string
    prize_name: string
    type: number
    update_time: string
    user_id: number
}

export function RewardLog(): Promise<RewardProps[]> {
    return http.post(`/api/bactroban-bus/rewardLog`).then(res => res?.data)
}

// ### 中奖记录详情
export function RewardDetail(params: { id: number }): Promise<RewardProps> {
    return http.get(`/api/bactroban-bus/reward/detail`, { params }).then(res => res?.data)
}


// ### 奖品列表
export function Prizes() {
    return http.post(`/api/bactroban-bus/prizes`)
}
